---------------------------
local scheme = ut.newSpellQueue()

local cisha = LoadScript("dz_cisha.lua")

scheme.add('死亡标记', nil, function( )
    return getBuffRemianTime('player', '死亡标记') < 5 --or true
end)
scheme.add('夜刃', 'target', function()
     return getDebuffRemainTime( 'target', '夜刃' ) < 3 
end)

scheme.add('赤喉之咬', 'target', function()
     return UnitIsPlayer('target')  
 end)

scheme.add('暗影之舞', nil, function( )
    return UnitExists('target')
    and getEnergy() > 80
    and not UnitBuff('player','暗影之舞') 
    and GetShapeshiftForm() == 0
    and IsSpellInRange('暗影打击', 'target') == 1
end)


scheme.add('刺骨', 'target', function()
	return getComboPoints() >= 4 and getDebuffRemainTime( 'target', '夜刃' ) > 0
end)

scheme.add('暗影打击', 'target')

scheme.add('背刺', 'target', function(  )
	-- return getComboPoints() < MaxComboPoints() and  getEnergy() > MaxEnergy() - 20 or getComboPoints() < 1 and getEnergy() > 40
    return  GetShapeshiftForm() == 0 and getCD('暗影之舞') > 1
end)


-------------------------------------------------------------------------------
function scheme.anyingzhiwu()
     s.sf_then_start('暗影之舞', nil,function() 
        return  not UnitBuff('player','暗影之舞')
    end)
end

function scheme.xiaoshi()
    s.sf_then_stop('消失', nil)
end

function scheme.mengun(idx)
    s.sf_then_stop('闷棍', 'arena' .. idx)
end

function scheme.cigu(  )
    if getComboPoints()>=4 then
         s.sf_then_start('刺骨', 'target')   -- body
    end
end

function scheme.startcs( )
    -- body
    if not UnitExists('target') then
        return
    end
    if GetDistanceBetweenObjects('player', 'target') > 10 then
        s.sf_then_start('飞镖投掷', 'target')
    else
        s.start()
    end
end

registerEvent('PLAYER_LEAVE_COMBAT', function( ... )
    -- print('PLAYER_LEAVE_COMBAT')
    -- s.weakStop()
end)

registerEvent('PLAYER_ENTER_COMBAT', function( ... )
    -- print('PLAYER_ENTER_COMBAT')
end)

-- registerEvent('UNIT_TARGET', function( ... )
    -- print(...)
-- end)

editWowMacro('暗影之舞', [[
#showtooltip 暗影之舞
/run s.anyingzhiwu()
]])

editWowMacro('刺骨', [[
#showtooltip 刺骨
/run s.cigu()
]])

editWowMacro('消失', [[
#showtooltip 消失
/run s.xiaoshi()
]])

editWowMacro('闷棍t', [[
#showtooltip 闷棍
/run s.sf_then_stop('闷棍', 'target')
]])
editWowMacro('飞镖投掷', [[
#showtooltip 飞镖投掷
/run s.sf_then_weakStop('飞镖投掷', 'target')
]])

scheme.touxi = cisha.touxi
scheme.touxiOther = cisha.touxiOther
scheme.zaoji = cisha.zaoji
scheme.shenji = cisha.shenji
scheme.tianjiangshaji = cisha.tianjiangshaji
-- scheme.mengun = cisha.mengun
scheme.yanggong = cisha.yanggong
scheme.zhimang = cisha.zhimang
scheme.daduan = cisha.daduan
scheme.isMorph = cisha.isMorph
scheme.morph = cisha.morph
scheme.zhuazei = cisha.zhuazei
scheme.feishen = cisha.feishen
return scheme

